//Source file: D:\\WTK104\\apps\\Toddtris\\src\\com\\toddsoft\\toddtris\\midlet\\DefaultKeyHandler.java

package com.toddsoft.toddtris.midlet;

import javax.microedition.lcdui.Canvas;

class DefaultKeyHandler extends KeyHandler {
    private Canvas canvas;
    
    /**
     * @param canvas
     */
    DefaultKeyHandler(Canvas canvas) {
        this.canvas = canvas;     
    }
    
    /**
     * @param keyCode
     * @return int
     */
    public int translateKeyCode(int keyCode) {
        switch (canvas.getGameAction(keyCode)) {
        case Canvas.LEFT:
            return LEFT;
        case Canvas.RIGHT:
            return RIGHT;
        case Canvas.FIRE:
            return CLOCKWISE;
        case Canvas.GAME_A:
        case Canvas.UP:
            return ANTICLOCKWISE;
        case Canvas.DOWN:
            return DOWN;
        case Canvas.GAME_B:
            return DROP;
        default:
            return -1;
        }     
    }
}
